package com.ruoyi.web.wapper;

import cn.hutool.core.util.DesensitizedUtil;
import cn.hutool.core.util.StrUtil;
import com.ruoyi.common.enums.BaseStatusEnum;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.wapper.BaseControllerWrapper;
import com.ruoyi.market.enums.SpecialEnum;
import org.apache.commons.lang3.ObjectUtils;

import java.math.BigInteger;
import java.util.List;
import java.util.Map;

public class MemberInfoWapper extends BaseControllerWrapper {

    public MemberInfoWapper(Map<String, Object> single) {
        super(single);
    }

    public MemberInfoWapper(List<Map<String, Object>> multi) {
        super(multi);
    }

    @Override
    public void wrapTheMap(Map<String, Object> map) {

        try {

            Integer extInfoFlag = (Integer) map.get("extInfoFlag");
            if (ObjectUtils.isNotEmpty(extInfoFlag)){
                String text = extInfoFlag==1?"已认证":"未认证";
                map.put("extInfoFlag", text);
            }

            BigInteger uid = (BigInteger) map.get("uid");
            if (ObjectUtils.isNotEmpty(uid)){
                map.put("uid", String.valueOf(uid));
            }

            String mobile = (String) map.get("mobile");
            if (StrUtil.isNotEmpty(mobile)){
                map.put("mobile", "");
                map.put("mobileStr", DesensitizedUtil.mobilePhone(mobile));
            }

            String idCard = (String) map.get("idCard");
            if (StrUtil.isNotEmpty(idCard)){
                map.put("idCard", "");
                map.put("idCardStr", DesensitizedUtil.idCardNum(idCard, 3,4));
            }

            String username = (String) map.get("username");
            if (StrUtil.isNotEmpty(username)){
                map.put("username", "");
                map.put("usernameStr", DesensitizedUtil.chineseName(username));
            }

            String zhima = (String) map.get("zhima");
            if (StrUtil.isNotEmpty(zhima)){
                map.put("zhimaStr", SpecialEnum.ZhimaScore.getNameByValue(zhima));
            }

        }catch (Exception ex){
            ex.printStackTrace();
        }
    }
}
